﻿using OneStationFile.IBLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace OneStationFile.WEB.Controllers
{
    public class CommonController : Controller
    {
         protected   IBaseService BaseService { get; set; }
        // GET: Common
        public ActionResult Index()
        {
            return View();
        }
        /// <summary>
        /// 获取node 等级不同的models
        /// </summary>
        /// <returns></returns>
        public static SelectList GetNodeLevelModels(int levelD = 1) {
            var bases = new BLL.BaseService();
            IEnumerable<Model.Node> nodes = bases.GetModels<Model.Node>().List().Where(p => Convert.ToInt32(p.NodeLevelD) == levelD);
            return new SelectList(nodes, "Id", "Name");
        }
        /// <summary>
        /// Left 左侧菜单
        /// </summary>
        /// <returns></returns>
        public ActionResult Left() {
            List<Model.Modular> modulars = BaseService.GetModels<Model.Modular>().List().Where(p => Convert.ToInt32(p.IsShow) == 1).ToList();
            //foreach (Model.Modular modular in modulars)
            //{
            //    if (modular.Nodes!= null)
            //    {
            //        modular.Nodes =  modular.Nodes as ISet<Model.Node>;
            //    }
            //}
            return View(modulars);
        }
        public ActionResult Top() {
            Model.Users users = null;
            //Model.Users users = Common.CacheHelper.GetCache("users") as Model.Users;
            users = BaseService.GetModelByWhere<Model.Users>(p => p.Account == "admin" && p.Name == "admin");
            ViewData["users"] = users;
            return View();
        }
    }
}